package com.sjy.ylxt.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaMode;
import com.sjy.ylxt.entity.basic.ResultBody;
import com.sjy.ylxt.entity.dto.HandleComplaintsDTO;
import com.sjy.ylxt.entity.dto.QueryComplaintsDTO;
import com.sjy.ylxt.service.YlxtComplaintsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: 史俊颖
 * @CreateTime: 2024-12-20
 * @Description: 投诉管理
 */
/**
 * 投诉管理
 */
@RestController
@RequestMapping("/complaints")
public class ComplaintsController {

    @Resource
    private YlxtComplaintsService complaintsService;


    /**
     * 分页查询投诉列表
     * @param pageNum
     * @param pageSize
     * @param patientId
     * @param companionId
     * @param complaintDate
     * @param complaintStatus
     * @return
     */
    @PostMapping("/page-list")
    public ResultBody<?> pageList(
            @RequestParam(required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(required = false) String patientId,
            @RequestParam(required = false) String companionId,
            @RequestParam(required = false) String complaintDate,
            @RequestParam(required = false) String complaintStatus) {
        QueryComplaintsDTO dto = new QueryComplaintsDTO();
        dto.setPageNum(pageNum);
        dto.setPageSize(pageSize);
        dto.setPatientId(patientId);
        dto.setCompanionId(companionId);
        dto.setComplaintDate(complaintDate);
        dto.setComplaintStatus(complaintStatus);
        return complaintsService.pageList(dto);
    }

    /**
     * 处理投诉
     */
    @PostMapping("/handle")
    public ResultBody<?> handleComplaints(
            @RequestParam String id,
            @RequestParam String desc,
            @RequestParam String status) {
        HandleComplaintsDTO dto = new HandleComplaintsDTO();
        dto.setId(id);
        dto.setDesc(desc);
        dto.setStatus(Integer.valueOf(status));
        return complaintsService.handleComplaints(dto);
    }
}
